package com.coding.kan_yi_dao.controller;


import com.coding.kan_yi_dao.common.Result;
import com.coding.kan_yi_dao.entity.GoodsInfo;
import com.coding.kan_yi_dao.service.impl.GoodsInfoServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 砍一刀，不买就砍你一刀
 * @since 2023-09-20
 */
@Api(tags = "商品配置")
@RestController
@RequestMapping("/goods-info")
@CrossOrigin
public class GoodsInfoController {

    @Resource
    GoodsInfoServiceImpl goodsInfoService;

    //TODO 全查询
    @ApiOperation(value = "全查询")
    @GetMapping("/go_select/goodsinfo")
    public Result go_select(GoodsInfo goodsInfo) {
        return goodsInfoService.go_select(goodsInfo);
    }

    //TODO 修改
    @ApiOperation(value = "修改操作")
    @GetMapping("/go_update/goodsino")
    public Result go_update(GoodsInfo goodsInfo) {
        return goodsInfoService.go_update(goodsInfo);
    }

    //TODO 修改
    @ApiOperation(value = "上架商品")
    @GetMapping("/go_update/insert/goodsinfo")
    public Result go_update_insert(@RequestParam(value = "ids", required = false) List<Integer> ids) {
        return goodsInfoService.go_update_insert(ids);
    }

    //TODO 修改
    @ApiOperation(value = "下架商品")
    @GetMapping("/go_update/delete/goodsinfo")
    public Result go_update_delete(@RequestParam(value = "ids", required = false) List<Integer> ids) {
        return goodsInfoService.go_update_delete(ids);
    }

    //TODO 模糊查询
    @ApiOperation(value = "模糊查询")
    @GetMapping("/go_select_like/goodsinfo")
    public Result go_select_like(String goodsname){
        return goodsInfoService.go_select_like(goodsname);
    }

    //TODO 分类搜索
    @ApiOperation(value = "分类搜索")
    @GetMapping("/go_info/goods")
    public Result go_info_goods(GoodsInfo goodsInfo){
        return goodsInfoService.go_info_goods(goodsInfo);
    }

    //TODO 添加商品
    @ApiOperation(value = "添加商品")
    @PostMapping("/go_info/insert")
    public Result go_info_goods_insert(GoodsInfo goodsInfo){
        return goodsInfoService.go_info_insert(goodsInfo);
    }
}
